home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
DYN401.ZIP
/
class
/
ushrtint.d
< prev
next >
Wrap
Text File
|
1996-06-26
|
2KB
|
137 lines
/*
*
* Copyright (c) 1993-1996 Algorithms Corporation
* 3020 Liberty Hills Drive
* Franklin, TN 37067
*
* ALL RIGHTS RESERVED.
*
*
*
*/
#include <math.h>
defclass UnsignedShortInteger : Number {
unsigned short int iVal;
};
cmeth gNewWithUnsigned, <vNew> (unsigned val)
{
object obj = gNew(super);
ivType *iv = ivPtr(obj);
iVal = (unsigned short int) val;
return(obj);
}
imeth int gHash()
{
double t;
t = .6125423371 * iVal;
t = t < 0.0 ? -t : t;
return (int) (BIG_INT * (t - floor(t)));
}
imeth int gCompare(obj)
{
unsigned short sv, ov;
ChkArg(obj, 2);
if (ClassOf(obj) != CLASS)
return gCompare(super, obj);
if ((sv=iVal) < (ov=ivPtr(obj)->iVal))
return -1;
else if (sv == ov)
return 0;
else
return 1;
}
imeth gStringRepValue()
{
return vSprintf(String, "%hu", iVal);
}
imeth char gCharValue()
{
return (char) iVal;
}
imeth short gShortValue()
{
return (short) iVal;
}
imeth unsigned short gUnsignedShortValue()
{
return (unsigned short) iVal;
}
imeth long gLongValue()
{
return (long) iVal;
}
imeth double gDoubleValue()
{
return (double) iVal;
}
imeth void *gPointerValue()
{
return (void *) &iVal;
}
imeth gChangeValue(val)
{
ChkArg(val, 2);
iVal = gUnsignedShortValue(val);
return self;
}
imeth gChangeCharValue(int val)
{
iVal = (unsigned short) val;
return self;
}
imeth gChangeShortValue(int val)
{
iVal = (unsigned short) val;
return self;
}
imeth gChangeUShortValue(unsigned val)
{
iVal = (unsigned short) val;
return self;
}
imeth gChangeLongValue(long val)
{
iVal = (unsigned short) val;
return self;
}
imeth gChangeDoubleValue(double val)
{
iVal = (unsigned short) val;
return self;
}
/*
*
* Copyright (c) 1993-1996 Algorithms Corporation
* 3020 Liberty Hills Drive
* Franklin, TN 37067
*
* ALL RIGHTS RESERVED.
*
*
*
*/